package com.jiang.jixiang.ui;

import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;

import com.gyf.barlibrary.ImmersionBar;
import com.jiang.jixiang.databinding.ActivityLauncherBinding;
import com.ws.universal.tools.Constants;
import com.ws.universal.tools.base.BaseActivity;
import com.ws.universal.tools.utils.CacheUtils;
import com.ws.universal.tools.utils.LanguageUtils;

public class LauncherActivity extends BaseActivity {
    private ActivityLauncherBinding binding;

    @Override
    protected void initCreate(Bundle savedInstanceState) {
        //沉浸式
        ImmersionBar.with(this)
                .statusBarDarkFont(false)
                .statusBarColor(com.ws.universal.tools.R.color.transparent)
                .fitsSystemWindows(false)  //使用该属性必须指定状态栏的颜色，不然状态栏透明，很难看
                .init();
        binding = ActivityLauncherBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());

    }

    @Override
    protected void initView() {
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                startMain();
            }
        }, 1000);




    }

    @Override
    protected void FinishDesTroy() {

    }

    private void startMain() {

        if (!CacheUtils.getBoolean(Constants.isFristInstall)) {
            CacheUtils.setBoolean(Constants.isFristInstall, true);
            String languageCode = LanguageUtils.getSystemLanguage().getDisplayLanguage();
            if (languageCode.equals("English")) {
                if (TextUtils.isEmpty(CacheUtils.getString(Constants.langCode))) {
                    CacheUtils.setString(Constants.langCode, "en-us");
                }
            } else if (languageCode.equals("中文")) {
                if (TextUtils.isEmpty(CacheUtils.getString(Constants.langCode))) {
                    CacheUtils.setString(Constants.langCode, "zh-cn");
                }
            } else if (languageCode.equals("Pусск")) {
                if (TextUtils.isEmpty(CacheUtils.getString(Constants.langCode))) {
                    CacheUtils.setString(Constants.langCode, "ru-ru");
                }
            } else {
                if (TextUtils.isEmpty(CacheUtils.getString(Constants.langCode))) {
                    CacheUtils.setString(Constants.langCode, "en-us");
                }
            }

        }
        pageJumpKill(MainActivity.class);
    }
}
